package com.monitor.service.impl;

import com.monitor.commons.SkList;
import com.monitor.commons.StringUtil;
import com.monitor.dao.IPermissionGroupDao;
import com.monitor.modelExt.GroupRightsExt;
import com.monitor.modelExt.PermissionGroupExt;
import com.monitor.pubInter.AbstractBaseService;
import com.monitor.pubInter.IBaseDao;
import com.monitor.pubInter.exception.SkException;
import com.monitor.searchExt.PermissionGroupSearchExt;
import com.monitor.service.IGroupRightsService;
import com.monitor.service.IPermissionGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
*    @author afeng
*    @Date 2025-03-17 10:50:14
*    @description PermissionGroupService      权限组
*/
@Service(value = "permissionGroupService")
@Slf4j
public class PermissionGroupServiceImpl extends AbstractBaseService<PermissionGroupExt, PermissionGroupSearchExt,String> implements IPermissionGroupService {

    @Resource(name = "permissionGroupDao")
    private IPermissionGroupDao permissionGroupDao;
    private IGroupRightsService groupRightsService;
    @Override
    public IBaseDao<PermissionGroupExt, PermissionGroupSearchExt,String> getDao() {
        return permissionGroupDao;
    }




    private void addRights(PermissionGroupExt obj) throws SkException {


        List<String> rightsIds = obj.getRightsIds();
        List<GroupRightsExt> groupRightsList = SkList.getInstance();
        if (StringUtil.isNotObjEmpty(rightsIds)) {
            rightsIds.stream().forEach(item -> {
                GroupRightsExt groupRights = new GroupRightsExt();
                groupRights.setGroupId(obj.getId());
                groupRights.setRightsId(item);
                groupRightsList.add(groupRights);

            });
            if (StringUtil.isNotObjEmpty(groupRightsList)) {
                groupRightsService.batchInsert(groupRightsList);
            }
        }
    }





}